package cn.tedu.travelsystem.order.mapper;

import cn.tedu.travelsystem.order.pojo.entity.Order;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Mapper
@Repository
public interface OrderMapper {
    int insertOrder(Order order);
    int deleteOrderById(Long orderId);
    Order getOrderById(Long orderId);
    int updateOrderStatus(@Param("orderId") Long orderId, @Param("status") Order.OrderStatus status);
    List<Order> selectExpiredOrders(@Param("timeoutMinutes") int timeoutMinutes);
    Order selectById(Long orderId);
    // OrderMapper接口
    void simpleInsertOrder(Order order);
    int updateOrderStatusIfPending(
            @Param("orderId") Long orderId,
            @Param("oldStatus") Order.OrderStatus oldStatus,
            @Param("newStatus") Order.OrderStatus newStatus
    );
    // OrderMapper.java
    List<Order> getPendingOrdersCreatedBefore(
            @Param("createTime") Date createTime,
            @Param("offset") int offset,
            @Param("limit") int limit
    );
    // 查询创建时间早于指定时间的待支付订单
    List<Order> getPendingOrdersCreatedBefore(Date createTime);
}
